/*
 * @Author: huyuhang
 * @Data:
 * @LastEditors: huyuhang
 * @LastEditTime: 2024-05-07 11:58:42
 * @Description: 数据采集结果页面列表columns字段
 */
import { renderFinger, renderClassification, renderLevel } from '@/utils/commonRender'
import { Hide, View } from '@element-plus/icons-vue'
const handleShowIp = (row) => {
  row.isShowIp = !row?.isShowIp
}
export const columns = {
  fieldColumns: [
    {
      label: '字段名称',
      prop: 'column'
    },
    {
      label: '字段描述',
      prop: 'comment'
    },
    {
      label: '所属表',
      prop: 'table'
    },
    {
      label: '所属schema',
      prop: 'schema',
      width: 110
    },
    {
      label: '所属库',
      prop: 'database'
    },
    {
      label: '资产IP:端口',
      render: ({ row }) => {
        return (
          <>
            <div style="display:flex;align-items:center;justify-content:space-between;">
              {row?.isShowIp ? (
                <span>{row.port ? row.ip + ':' + row.port : row.ip}</span>
              ) : (
                <span style="font-size:17px">***********</span>
              )}
              {row?.isShowIp ? (
                <el-icon>
                  <Hide onClick={() => handleShowIp(row)} />
                </el-icon>
              ) : (
                <el-icon>
                  <View onClick={() => handleShowIp(row)} />
                </el-icon>
              )}
            </div>
          </>
        )
      }
    },
    {
      label: '资产类型',
      prop: 'assetType'
    },
    {
      label: '数据源名称',
      prop: 'dataSourceName'
    },
    {
      label: '组件来源',
      prop: 'sourceName'
    },
    {
      label: '归属机构',
      prop: 'department'
    },
    {
      label: '归属系统',
      prop: 'system'
    },
    {
      label: '分类',
      prop: 'classification'
    },
    {
      label: '分级',
      render: renderLevel
    },
    {
      width: '40px'
    }
  ],
  tableColumns: [
    {
      label: '表名称',
      prop: 'table'
    },
    {
      label: '表描述',
      prop: 'comment'
    },
    {
      label: '所属schema',
      prop: 'schema',
      width: 110
    },
    {
      label: '所属库',
      prop: 'database'
    },
    {
      label: '资产IP:端口',
      render: ({ row }) => {
        return (
          <>
            <div style="display:flex;align-items:center;justify-content:space-between;">
              {row?.isShowIp ? (
                <span>{row.port ? row.ip + ':' + row.port : row.ip}</span>
              ) : (
                <span style="font-size:17px">***********</span>
              )}
              {row?.isShowIp ? (
                <el-icon>
                  <Hide onClick={() => handleShowIp(row)} />
                </el-icon>
              ) : (
                <el-icon>
                  <View onClick={() => handleShowIp(row)} />
                </el-icon>
              )}
            </div>
          </>
        )
      }
    },
    {
      label: '资产类型',
      prop: 'assetType'
    },
    {
      label: '数据源名称',
      prop: 'dataSourceName'
    },
    {
      label: '组件来源',
      prop: 'sourceName'
    },
    {
      label: '归属机构',
      prop: 'department'
    },
    {
      label: '归属系统',
      prop: 'system'
    },
    {
      label: '分类',
      prop: 'classification'
    },
    {
      label: '分级',
      render: renderLevel
    },
    {
      width: '40px'
    }
  ],
  schemaColumns: [
    {
      label: 'schema名称',
      prop: 'schema'
    },
    {
      label: '所属库',
      prop: 'database'
    },
    {
      label: '资产IP:端口',
      render: ({ row }) => {
        return (
          <>
            <div style="display:flex;align-items:center;justify-content:space-between;">
              {row?.isShowIp ? (
                <span>{row.port ? row.ip + ':' + row.port : row.ip}</span>
              ) : (
                <span style="font-size:17px">***********</span>
              )}
              {row?.isShowIp ? (
                <el-icon>
                  <Hide onClick={() => handleShowIp(row)} />
                </el-icon>
              ) : (
                <el-icon>
                  <View onClick={() => handleShowIp(row)} />
                </el-icon>
              )}
            </div>
          </>
        )
      }
    },
    {
      label: '资产类型',
      prop: 'assetType'
    },
    {
      label: '数据源名称',
      prop: 'dataSourceName'
    },
    {
      label: '组件来源',
      prop: 'sourceName'
    },
    {
      label: '归属机构',
      prop: 'department'
    },
    {
      label: '归属系统',
      prop: 'system'
    },
    {
      width: '40px'
    }
  ],
  baseColumns: [
    {
      label: '库名称',
      prop: 'database'
    },
    {
      label: '资产IP:端口',
      render: ({ row }) => {
        return (
          <>
            <div style="display:flex;align-items:center;justify-content:space-between;">
              {row?.isShowIp ? (
                <span>{row.port ? row.ip + ':' + row.port : row.ip}</span>
              ) : (
                <span style="font-size:17px">***********</span>
              )}
              {row?.isShowIp ? (
                <el-icon>
                  <Hide onClick={() => handleShowIp(row)} />
                </el-icon>
              ) : (
                <el-icon>
                  <View onClick={() => handleShowIp(row)} />
                </el-icon>
              )}
            </div>
          </>
        )
      }
    },
    {
      label: '资产类型',
      prop: 'assetType'
    },
    {
      label: '数据源名称',
      prop: 'dataSourceName'
    },
    {
      label: '组件来源',
      prop: 'sourceName'
    },
    {
      label: '归属机构',
      prop: 'department'
    },
    {
      label: '归属系统',
      prop: 'system'
    },
    {
      width: '40px'
    }
  ],
  componentColumns: [
    {
      label: '资产IP:端口',
      render: ({ row }) => {
        return (
          <>
            <div style="display:flex;align-items:center;justify-content:space-between;">
              {row?.isShowIp ? (
                <span>{row.port ? row.ip + ':' + row.port : row.ip}</span>
              ) : (
                <span style="font-size:17px">***********</span>
              )}
              {row?.isShowIp ? (
                <el-icon>
                  <Hide onClick={() => handleShowIp(row)} />
                </el-icon>
              ) : (
                <el-icon>
                  <View onClick={() => handleShowIp(row)} />
                </el-icon>
              )}
            </div>
          </>
        )
      }
    },
    {
      label: '资产类型',
      prop: 'assetType'
    },
    {
      label: '数据源名称',
      prop: 'dataSourceName'
    },
    {
      label: '组件来源',
      prop: 'sourceName'
    },
    {
      label: '归属机构',
      prop: 'department'
    },
    {
      label: '归属系统',
      prop: 'system'
    },
    {
      width: '40px'
    }
  ],
  fileColumns: [
    {
      label: '文件名称',
      prop: 'fileName'
    },
    {
      label: '文件类型',
      prop: 'fileType'
    },
    {
      label: '文件大小',
      render: ({ row }) => {
        return (
          <>
            <span>{row.fileSize + ' B'}</span>
          </>
        )
      }
    },
    {
      label: '文件路径',
      prop: 'absolutePath'
    },
    {
      label: '文件指纹',
      render: renderFinger
    },
    {
      label: '资产IP:端口',
      render: ({ row }) => {
        return (
          <>
            <div style="display:flex;align-items:center;justify-content:space-between;">
              {row?.isShowIp ? (
                <span>{row.port ? row.ip + ':' + row.port : row.ip}</span>
              ) : (
                <span style="font-size:17px">***********</span>
              )}
              {row?.isShowIp ? (
                <el-icon>
                  <Hide onClick={() => handleShowIp(row)} />
                </el-icon>
              ) : (
                <el-icon>
                  <View onClick={() => handleShowIp(row)} />
                </el-icon>
              )}
            </div>
          </>
        )
      }
    },
    {
      label: '资产类型',
      prop: 'assetType'
    },
    {
      label: '数据源名称',
      prop: 'dataSourceName'
    },
    {
      label: '归属机构',
      prop: 'department'
    },
    {
      label: '归属系统',
      prop: 'system'
    },
    {
      label: '分类',
      prop: 'classification'
    },
    {
      label: '分级',
      render: renderLevel
    },
    {
      width: '40px'
    }
  ]
}
